home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / kernel / utils / dump.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-12-19  |  7.6 KB  |  303 lines

  1. /* 
  2.  * dump.c --
  3.  *
  4.  *    Routines to print global system states in a readable form.  Examples
  5.  *    of structures that can be dumped are:
  6.  *
  7.  *        * timer queue
  8.  *        * process table
  9.  *        * queue of ready processes.
  10.  *
  11.  * Copyright 1985 Regents of the University of California
  12.  * All rights reserved.
  13.  */
  14.  
  15. #ifndef lint
  16. static char rcsid[] = "$Header: /cdrom/src/kernel/Cvsroot/kernel/utils/dump.c,v 9.13 91/09/17 15:08:04 shirriff Exp $ SPRITE (Berkeley)";
  17. #endif /* not lint */
  18.  
  19.  
  20. #include <net.h>
  21. #include <sprite.h>
  22. #include <mach.h>
  23. #include <dump.h>
  24. #include <dumpInt.h>
  25. #include <timer.h>
  26. #include <proc.h>
  27. #include <sys.h>
  28. #include <list.h>
  29. #include <devVid.h>
  30. #include <rpc.h>
  31. #include <fs.h>
  32. #include <fsutil.h>
  33. #include <fscache.h>
  34. #include <fspdev.h>
  35. #include <recov.h>
  36. #include <string.h>
  37. #include <sched.h>
  38. #include <devSyslog.h>
  39. #include <mem.h>
  40. #include <stdio.h>
  41.  
  42. /*
  43.  * Forward references to procedures internal to this file.
  44.  */
  45. static void    DumpProcTable _ARGS_((ClientData));
  46. static void    PrintL1Menu _ARGS_((ClientData));
  47. static void    PrintTOD _ARGS_((ClientData));
  48. static void    PrintVersion _ARGS_((ClientData));
  49. static void    ResetNetworks _ARGS_((ClientData));
  50. static void    VidEnable _ARGS_((ClientData));
  51.  
  52. /*
  53.  * Table of routines and their arguments to be called on dump events.
  54.  * Only machine independent dump events should be added to this table.
  55.  * Machine dependent event should be added to the Local event table.
  56.  *
  57.  * These events are registered in the machine dependent dumpEvents.c
  58.  * This does Dev_RegisterConsoleCmd.  They are called in devConsoleCmds.c.
  59.  */
  60. static EventTableType eventTable[] = {
  61.     {'/', PrintL1Menu, (ClientData)0, "Print Dump Event Menu"},
  62.     {'a', RESERVED_EVENT, NULL_ARG, "Abort to PROM monitor" }, 
  63.     {'c', Fscache_DumpStats, (ClientData)0, "Dump cache stats"},
  64.     {'d', RESERVED_EVENT, NULL_ARG, "Put machine into the kernel debugger"},
  65.     {'e', Timer_DumpStats, (ClientData) 'e', "Dump timer stats"},
  66. #ifdef notdef
  67.     {'f', Fsutil_PrintTrace, (ClientData) -1, "Dump filesystem trace"},
  68. #endif
  69.     {'i', Proc_KDump, (ClientData) 0, "Info on waiting processes"},
  70.     {'j', Dev_SyslogDisable, (ClientData) 0, "Disable/enable syslog"},
  71.     {'m', Mem_DumpStats, (ClientData) FALSE, "Dump memory stats"},
  72.     {'n', ResetNetworks, (ClientData)0, "Reset the network interfaces"},
  73.     {'o', VidEnable, (ClientData) 1, "Turn video on"},
  74.     {'p', DumpProcTable, (ClientData) 0, "Dump process table"},
  75.     {'r', Sched_DumpReadyQueue, (ClientData) 0, "Dump ready queue"},
  76. #ifdef notdef
  77.     {'q', Fspdev_PrintTrace, (ClientData) 200, "Dump pseudo-device trace"},
  78. #endif
  79.     {'s', Timer_DumpStats,   (ClientData) 's', "Reset timer stats"},
  80.     {'t', Timer_DumpQueue,  (ClientData) 0, "Dump the timer queue"},
  81.     {'v', PrintVersion, (ClientData) 0, "Print version string of the kernel"},
  82.     {'w', Fsutil_SyncStub, (ClientData) FALSE, "WRITE BACK CACHE"},
  83.     {'x', Fsutil_HandleScavengeStub, (ClientData) 0, 
  84.                     "Scavenge filesystem handles"},
  85.     {'y', Recov_PrintTrace, (ClientData) 50, "Dump RPC recovery trace"},
  86.     {'z', Rpc_PrintTrace, (ClientData) 50, "Dump RPC packet trace"},
  87.     {'1', Timer_TimerGetInfo, (ClientData) 1,"Dump info for timer counter 1"},
  88.     {'2', Timer_TimerGetInfo, (ClientData) 2,"Dump info for timer counter 2"},
  89.     {'3', Timer_TimerGetInfo, (ClientData) 3,"Dump info for timer counter 3"},
  90.     {'4', Timer_TimerGetInfo, (ClientData) 4,"Dump info for timer counter 4"},
  91.     {'5', Timer_TimerGetInfo, (ClientData) 5,"Dump info for timer counter 5"},
  92.     {'6', PrintTOD,           (ClientData) 0,"Print time of day counters"},
  93.     /* This MUST be the last entry */
  94.     {'\0', LAST_EVENT,        NULL_ARG,       (char *) 0 },
  95. };
  96.  
  97.  
  98.  
  99. /*
  100.  *----------------------------------------------------------------------
  101.  *
  102.  * Dump_Init --
  103.  *
  104.  *    Establish default procedural attachments for Dump events.
  105.  *
  106.  * Results:
  107.  *    None.
  108.  *
  109.  * Side effects:
  110.  *    None. 
  111.  *
  112.  *----------------------------------------------------------------------
  113.  */
  114.  
  115. void
  116. Dump_Init()
  117. {
  118.     Dump_Register_Events(eventTable);
  119.  
  120. }
  121.  
  122.  
  123. /*
  124.  *----------------------------------------------------------------------
  125.  *
  126.  * DumpProcTable --
  127.  *
  128.  *    Wrapper to avoid casts and compiler warnings.
  129.  *
  130.  * Results:
  131.  *    None.
  132.  *
  133.  * Side effects:
  134.  *    (see Proc_Dump.)
  135.  *
  136.  *----------------------------------------------------------------------
  137.  */
  138.  
  139. /* ARGSUSED */
  140. static void
  141. DumpProcTable(dummy)
  142.     ClientData dummy;
  143. {
  144.     Proc_Dump();
  145. }
  146.  
  147. /*
  148.  *----------------------------------------------------------------------
  149.  *
  150.  * PrintL1Menu --
  151.  *
  152.  *    Dump out a list of the L1-key magic commands.
  153.  *
  154.  * Results:
  155.  *    None.
  156.  *
  157.  * Side effects:
  158.  *    None.
  159.  *
  160.  *----------------------------------------------------------------------
  161.  */
  162.  
  163. /* ARGSUSED */
  164. static void
  165. PrintL1Menu(arg)
  166.     ClientData arg;        /* unused */
  167. {
  168.     EventTableType    *entry;
  169.  
  170.     printf("Pressing the L1 key and a letter causes the following...\n");
  171.     printf("/ or ? - Print this menu\n");
  172.     for (entry = eventTable; entry->routine != LAST_EVENT; entry++) {
  173.     printf("%c - %s\n",entry->key, entry->description);
  174.     }
  175.     /*
  176.      * Show the machine dependent bindings.
  177.      */
  178.     printf("Machine dependent entries....\n");
  179.     Dump_Show_Local_Menu();
  180. }
  181.  
  182.  
  183. /*
  184.  *----------------------------------------------------------------------
  185.  *
  186.  * PrintTOD --
  187.  *
  188.  *    Prints the time of day using one of two sources for the time.
  189.  *
  190.  * Results:
  191.  *    None.
  192.  *
  193.  * Side effects:
  194.  *    Output is written to the display.
  195.  *
  196.  *----------------------------------------------------------------------
  197.  */
  198. /*ARGSUSED*/
  199. static void
  200. PrintTOD(arg)
  201.     ClientData arg;        /* unused */
  202. {
  203.     Time time1, time2, diff;
  204.  
  205.     Timer_GetTimeOfDay(&time1, (int *) NIL, (Boolean *) NIL);
  206.     Timer_GetRealTimeOfDay(&time2, (int *) NIL, (Boolean *) NIL);
  207.     printf("Fast: %d.%06d\n", time1.seconds, time1.microseconds);
  208.     printf("Slow: %d.%06d\n", time2.seconds, time2.microseconds);
  209.     Time_Subtract(time2, time1, &diff);
  210.     printf("diff: %d.%06d\n", diff.seconds, diff.microseconds);
  211.  
  212.     /*
  213.     Timer_GetRealTimeOfDay(&time1, (int *) NIL, (Boolean *) NIL);
  214.     Timer_GetRealTimeOfDay(&time2, (int *) NIL, (Boolean *) NIL);
  215.     Time_Subtract(time2, time1, &diff);
  216.     printf("Slow diff: %d.%06d\n", diff.seconds, diff.microseconds);
  217.     */
  218. }
  219.  
  220.  
  221. /*
  222.  *----------------------------------------------------------------------
  223.  *
  224.  * PrintVersion --
  225.  *
  226.  *    Prints the kernel's version on the console.
  227.  *
  228.  * Results:
  229.  *    None.
  230.  *
  231.  * Side effects:
  232.  *    Output is written to the display.
  233.  *
  234.  *----------------------------------------------------------------------
  235.  */
  236. /*ARGSUSED*/
  237. static void
  238. PrintVersion(arg)
  239.     ClientData arg;        /* unused */
  240. {
  241.     extern char *SpriteVersion();
  242.     char *v;
  243.  
  244.     v = SpriteVersion();
  245.     printf("%s\n",v);
  246. }
  247.  
  248. /*
  249.  *----------------------------------------------------------------------
  250.  *
  251.  * ResetNetworks --
  252.  *
  253.  *    Reset all network interfaces.
  254.  *
  255.  * Results:
  256.  *    None.
  257.  *
  258.  * Side effects:
  259.  *    The network interfaces are reset.
  260.  *
  261.  *----------------------------------------------------------------------
  262.  */
  263. /*ARGSUSED*/
  264. static void
  265. ResetNetworks(arg)
  266.     ClientData arg;        /* unused */
  267. {
  268.     int            i;
  269.     Net_Interface    *interPtr;
  270.  
  271.     i = 0; 
  272.     interPtr = Net_NextInterface(FALSE, &i);
  273.     while (interPtr != (Net_Interface *) NIL) {
  274.     Net_Reset(interPtr);
  275.     i++;
  276.     interPtr = Net_NextInterface(FALSE, &i);
  277.     }
  278. }
  279.  
  280.  
  281. /*
  282.  *----------------------------------------------------------------------
  283.  *
  284.  * VidEnable --
  285.  *
  286.  *    Wrapper to avoid casts and compiler warnings.
  287.  *
  288.  * Results:
  289.  *    None.
  290.  *
  291.  * Side effects:
  292.  *    (see Dev_VidEnable.)
  293.  *
  294.  *----------------------------------------------------------------------
  295.  */
  296.  
  297. static void
  298. VidEnable(onOff)
  299.     ClientData onOff;
  300. {
  301.     Dev_VidEnable((Boolean)onOff);
  302. }
  303.